/-boot ...
BootController.ts
BootLayout.ts
StorageLoader.ts
boot.ts
/-docs
/-editor
/-files
/-files-old
/-imports
/-layout
/-storage
/-storage/attached
/-storage/attached/api
DetectStorage.ts
LoadStorage.ts
LoadStorageRecipient.ts
UpdateStorage.ts
/-storage/attached/dom
/-storage/attached/indexedDB
/-storage/attached/localStorage
/-storage/attached/webSQL
/-tests
/-typings
Dom.ts
TypeScriptService.ts
functions.ts
ko.ts
nteapo.html
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
try.html
try.js
xxxxxxxxxx
59
​
60
    private _detectCompleted() {
61
      var loadingFromPersistence = this._persistence && this._persistence.editedUTC > this._domStorage.editedUTC;
62
​
63
      var sourceLoad = loadingFromPersistence ? this._persistence : this._domStorage;
64
      var targetLoad = loadingFromPersistence ? this._domStorage : this._persistence;
65
​
66
      this._callbacks.detectionComplete(
67
        this._persistenceName,
68
        sourceLoad.editedUTC,
69
        targetLoad ? true : false);
70
      
71
      var byFullPath: { [fullPath: string]: { [property: string]: string; }; } = {};
72
      var loadedFileCount = 0;
73
      sourceLoad.load({
74
        file: (fullPath: string, values: { [name: string]: string; }) => { 
75
          byFullPath[fullPath] = values;
76
          loadedFileCount++;
77
          this._callbacks.loadProgress(loadedFileCount, fullPath);
78
        },
79
        completed: (sourceUpdater: storage.attached.UpdateStorage) => {
80
          if (!targetLoad) {
81
            this._callbacks.loadComplete();
82
            return;
83
          }
84
​
85
          targetLoad.migrate(sourceLoad.editedUTC, byFullPath, (err, targetupdater) => {
86
            if (err) {
87
              // TODO: propagate error
88
            }
89
​
90
            this._callbacks.loadComplete();
91
          });
92
        },
93
        failed: (error: Error) => {
94
          // TODO: propagate error
95
          this._callbacks.loadComplete();
96
        }
97
        
98
      });
99
      
100
      if (this._persistence) {
101
        // TODO: choose the source, do the migration, report
102
      }
103
      else {
104
        this._callbacks.detectionComplete('dom', this._domStorage.editedUTC, false);
105
      }
106
    }
107
​
108
  }
109
​
110
  export module StorageLoader {
111
​
112
    export interface Callbacks {
113
​
114
      detectionComplete(
115
        name: string,
116
        editedUTC: number,
117
        supportsPersistence: boolean): void;
118
​
89:43